Skip to content

feat(s3): add pandas_mode to to_csv to pass file open mode (e.g. a) t… - #3363

Open
bujjibabukatta wants to merge 10 commits into
aws:mainfrom
bujjibabukatta:fix/#2409
Open

feat(s3): add pandas_mode to to_csv to pass file open mode (e.g. a) t…#3363
bujjibabukatta wants to merge 10 commits into
aws:mainfrom
bujjibabukatta:fix/#2409

Conversation

@bujjibabukatta

Copy link
Copy Markdown
Contributor

Problem
wr.s3.to_csv() has a mode parameter for dataset write behaviour ("append", "overwrite"). pandas df.to_csv() also has a mode parameter for file open mode ("w", "a"). These collide — there was no way to pass pandas mode="a" to append to an existing file.
Solution
Add a pandas_mode parameter to to_csv that passes the file open mode through to pandas. Since S3 has no native append, the implementation reads the existing file content first and writes it back before appending the new data.
Changes

awswrangler/s3/_write_text.py — add pandas_mode param, implement S3-level append in _to_text, fix mode=mode being incorrectly passed to df.to_csv()
tests/unit/test_moto.py — add test_csv_pandas_mode_append

…hrough to pandas, resolving collision with dataset mode parameter
@bujjibabukatta

Copy link
Copy Markdown
Contributor Author

Hi @kukushking could you please review and approve pull request?

@kukushking kukushking left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bujjibabukatta

bujjibabukatta commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Hi @kukushking I fixed it.could you please review and approve pull request?

@bujjibabukatta

bujjibabukatta commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Hi @kukushking, @goleash-4alight I have fixed code . Please review and approve pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants